import { BaseModel } from '#/models/base';

export namespace ProductApi {
  export interface Product {
    product_id: number;
    product_type: string;
    sku: string;
    name: string;
    spc: string;
    description: string;
    category_id: number;
    unit_pr: string;
    unit_wh: string;
    unit_use: string;
    unit_rate: {
      pr_use?: number;
      pr_wh?: number;
      wh_use?: number;
    };
    status: string;
    remark?: string;
    creator: string;
    modifier: string;
    update_time: string;
    create_time: string;
    is_deleted: boolean;
    // 新增字段
    sku_supplier?: string;
    barcode?: string;
    inventory_method?: string;
    costing_method?: string;
    is_batch_tracked?: boolean;
    is_serial_tracked?: boolean;
    shelf_life_days?: number;
    safety_stock?: number;
    reorder_point?: number;
    max_stock?: number;
    default_warehouse_id?: number;
    default_location?: string;
    preferred_supplier_id?: number;
    purchaser_id?: number;
    lead_time?: number;
    moq?: number;
    last_purchase_price?: number;
    list_price?: number;
    standard_cost?: number;
    current_cost?: number;
    income_account_id?: number;
    cogs_account_id?: number;
    asset_account_id?: number;
    tax_code?: string;
    version?: string;
  }
}

export class ProductModel extends BaseModel<ProductApi.Product> {
  /**
   * 产品模型，用于与后端产品API交互
   * 注意：baseUrl需要与后端URL配置保持一致
   */
  constructor() {
    super('/product/product/');
  }
}
